$(function () {
    var defaultColunms = BaseTable.initColumn();
    var table = new BSTable(BaseTable.id, "/sys/log/list", defaultColunms);
    table.setPaginationType("server");
    BaseTable.table = table.init();
});

/**
 * 表格类容初始化
 */
var BaseTable = {
    id: "table",	//表格id
    seItem: null,		//选中的条目
    table: null,
};

/**
 * 初始化表格的列
 */
BaseTable.initColumn = function () {
    return [
        {field: 'selectItem',checkbox : true},
        {field: 'id',title : '序号',align: 'center', valign: 'middle',formatter : function(value, row, index) {return index+1;}},
        {title: '用户名', field: 'username', align: 'center', valign: 'middle', sortable: true},
        {title: '用户操作', field: 'operation', align: 'center', valign: 'middle', sortable: true},
        {title: '执行时长(毫秒)', field: 'time', align: 'center', valign: 'middle', sortable: true},
        {title: 'IP地址', field: 'ip', align: 'center', valign: 'middle', sortable: true},
        {title: '创建时间', field: 'createTime', align: 'center', valign: 'middle', sortable: true},
    ];
};

/**
 * 查询表格列表
 */
BaseTable.search = function () {
    var queryData = {};
    queryData['key'] = $("#key").val();
    BaseTable.table.refresh({query: queryData});
};

var vm = new Vue({
	el:'#app',
	methods: {
		reload: function (event) {
            BaseTable.search();
		}
	}
});